package com.cloud.exception;

public enum MyErrorEnum {
    //错误码
    errorParm(-1, "参数错误。"),
    ;

    private final int errorCode;
    private final String errorMsg;

    MyErrorEnum(int errorCode, String errorMsg) {
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public MyException getMyException() {
        return getMyException(errorMsg);
    }

    public MyException getMyException(String msg) {
        return new MyException(errorCode, "", msg);//  返回输入的错误信息
    }

    public int getErrorCode() {
        return errorCode;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public static MyErrorEnum findByCode(int code) {
        for (MyErrorEnum value : MyErrorEnum.values()) {
            if (value.errorCode == (code)) {
                return value;
            }
        }
        return null;
    }
}
